<cfcomponent>

	<cfset variables.instance = structNew() />
	
	<cffunction name="init" output="false" access="public" returntype="UserMsg" hint="I perform Initialization functions for this component">
		<cfargument name="delim" type="string" default="<br />"/>
		
		<cfset setUp() />

		<cfset variables.instance.delim = arguments.delim/>
		<cfreturn this />
	</cffunction>

	<cffunction name="addError" output="false" access="public" returntype="any" hint="I add an error message">
		<cfargument name="text" type="string" required="true"/>
		<cfset arrayAppend( getMsg(), arguments.text ) />
	</cffunction>
	<!--- todo: differentiate between the error and the success message flavors --->
	<cffunction name="addSuccess" output="false" access="public" returntype="any" hint="I add an success message">
		<cfargument name="text" type="string" required="true"/>
		<cfset arrayAppend( getMsg(), arguments.text ) />
	</cffunction>

	<cffunction name="display" output="false" access="public" returntype="any" hint="I return all messages">
		<cfset var outputList = arrayToList( getMsg(), getDelim() ) />
		<cfset reset() >
		<cfreturn outputList />
	</cffunction>
	
	<cffunction name="getDelim" access="private" output="false" returntype="string">
		<cfreturn variables.instance.Delim />
	</cffunction>
	
	<cffunction name="setDelim" access="public" output="false" returntype="void">
		<cfargument name="Delim" type="string" required="true" />
		<cfset variables.instance.Delim = arguments.Delim />
	</cffunction>
	
	<!--- 	Date: 11/5/2007  Usage: I return the internal messages --->
	<cffunction name="getMsg" output="false" access="private" returntype="any" hint="I return the internal messages">
		<cfreturn session.MessageArray />		
	</cffunction>
	
	<!--- 	Date: 11/11/2007  Usage: I set up the memory space for this component --->
	<cffunction name="setUp" output="false" access="private" returntype="any" hint="I set up the memory space for this component">
		<cfif NOT structKeyExists( session, "MessageArray" ) >
			<cfset session.MessageArray = arrayNew(1) />
		</cfif>
		
		<cfif NOT isArray( session.MessageArray ) >
			<cfset session.MessageArray = arrayNew(1) />
		</cfif>			
	</cffunction>

	<!--- 	Date: 11/11/2007  Usage: I reset the memory space for this component --->
	<cffunction name="reset" output="false" access="private" returntype="void" hint="I reset the memory space for this component">
		<cfset session.MessageArray = arrayNew(1) />
	</cffunction>

</cfcomponent>